package com.csdj.t309springboot.utils;

import java.util.TreeMap;

public class SignurateUtil {

    /**
     * 驗證簽名
     * @param map
     * @param sign
     * @return
     */
    public static boolean checkSign(TreeMap<String,String> map,String sign){
        String secretKey = "wienq31fj2ijsf21f2g3";
        StringBuilder sb = new StringBuilder();
        map.entrySet().forEach(item ->{
            sb.append(item.getKey()).append("=").append(item.getValue()).append("&");
        });
        sb.append("secretKey=").append(secretKey);
        String hash = EncryptUtil.getSha256(sb.toString());
        return sign.equals(hash);
    }
}
